package net.cathackers.devel.scmp.chat.impl.xmpp.presence;

import net.cathackers.devel.scmp.xmpp.PresencePacket;
/**
 * The class is presence information generator
 * the server gets that information from it
 * then sends it to the presence recipients
 *
 */

public class PresenceInformation {
    /**
     * the presence information is determined according to packet_ attribute
     * which is a presence packet 
     */
    private PresencePacket packet_;
    private boolean available_;
    /**
     * Default constructor creates new PresenceInformation object
     */
    
    public PresenceInformation(){
	
    }
    
    /**
     *
     * @return the user is available
     */
    
    public boolean isAvailable(){
	return available_;
    }
    /**
     * check the PresencePacket then
     * set the packet as available or unavailable
     * @param p a PresencePacket
     */

    public void setPacket(PresencePacket p){
	packet_ = p;
	switch (packet_.getPresenceType()) {
	case AVAILABLE:
	    setAvailability(true);
	    break;
	case UNAVAILABLE:
	    setAvailability(false);
	    break;
	}
    }
    /**
     * 
     * @return send  a packet determines if the user is available or not
     */
    public PresencePacket getPacket(){
	return packet_;
    }
    /**
     * set the availability
     * @param isAvailable
     */
    
    public void setAvailability(boolean isAvailable) {
	this.available_ = isAvailable;
    }

}
